// #ifndef VUE3
import Vue from 'vue'
import App from './App'

//	导入网络请求包——escook/request-miniprogram
import {
	$http
} from '@escook/request-miniprogram'

import uView from '@/uni_modules/uview-ui'
Vue.use(uView)


Vue.config.productionTip = false

App.mpType = 'app'

//	挂载属性
uni.$http = $http
$http.baseUrl = "http://localhost:8099"

// 请求开始之前做一些事情
$http.beforeRequest = function(options) {
	let authentication
	try {
		authentication = uni.getStorageSync('authentication');
		if (authentication) {
			console.log(authentication);
		}
	} catch (e) {
		// error
		console.log(e);
	}
	options.header = {
		'authentication': authentication
	}
	wx.showLoading({
		title: '数据加载中...',
	})
}

// 请求完成之后做一些事情
$http.afterRequest = function() {
	wx.hideLoading()
}

//	封装消息弹窗
uni.$showMsg = function(title = '数据加载失败...', duration = 2000) {
	uni.showToast({
		title,
		duration,
		icon: 'none'
	})
}

const app = new Vue({
	...App
})
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
import App from './App.vue'
import colorGradient from './uni_modules/uview-ui/libs/function/colorGradient'
export function createApp() {
	const app = createSSRApp(App)
	return {
		app
	}
}
// #endif